﻿/// <summary>
/// 
///	Author:		    Gerard Finn
///
///	Student No		X00115840
///
///	Date:			Start Date 	:- 22-03-2014
///	Modified					:-
/// 
/// File            Program.cs
///   
///	Description		Client base program
///
/// </summary>

using System;

namespace Client
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // Init variables in dialog output
            MakeUIDialog uiClass = new MakeUIDialog();

            // Display the user options allow for any input source
            // by keeping all IO functionality in one place
            uiClass.CreateUI();

            // Class to deal with the interfacing with the Azure cloud
            ProcessUserSelection userSelection = new ProcessUserSelection();

            bool successFailure = false;

            while ( uiClass.Choice != Selection.EXIT )
            {
                switch ( uiClass.Choice )
                {
                    case Selection.VIEWITEMS:               // View all items in list
                        successFailure = userSelection.getAllItems();
                        break;
                    case Selection.VIEWSINGLEITEM:          // View one items from the list
                        successFailure = userSelection.getSingleItem(IOScreen.ItemId);
                        break;
                    case Selection.ADDITEMNAME:             // Add an item name to list
                        successFailure = userSelection.postSingleItem(IOScreen.ItemId);
                        break;
                    case Selection.ADDITEMNAMEANDDATA:      // Add an item name and data to list
                        successFailure = userSelection.postItemStockData(IOScreen.StockData);
                        break;
                    case Selection.DELETEITEM:              // Delete a single item in the data set
                        successFailure = userSelection.deleteItem(IOScreen.ItemId);
                        break;
                    case Selection.MODIFYITEM:              // Modify a single item in the data set
                        successFailure = userSelection.putSingleItem(IOScreen.ItemId);
                        break;
                    case Selection.OTHER:                   // Stuff i havent thought of yet
                        ErrorMessage.Display("Havent thought of this yet ");
                        break;
                    default :                               // Unknown selection how did we get here ??
                        ErrorMessage.Display(LocalisationSettings.GetString("ErrorMessageUnknownString"));
                        break;
                }

                if (successFailure == true)
                {
                    SuccessMessage.Display(userSelection.SuccessMessage);
                    IOClass.ReadLine();         // Put a delay here so info can be seen
                }
                else
                {
                    ErrorMessage.Display(userSelection.ErrorMessage);
                    IOClass.ReadLine();
                }
                uiClass.CreateUI();
            }
        }
    }
}
